package com.bw.home.viewmodel

import android.util.Log
import androidx.lifecycle.viewModelScope
import com.bw.home.entity.VideoTypeEntity
import com.bw.home.repository.HomeIntent
import com.bw.home.repository.HomeRepository
import com.example.common.base.BaseViewModel
import com.example.common.base.Res
import com.example.common.base.StateType
import com.example.common.base.UiIntent
import com.example.common.base.UiState
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.flow.flowOn
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import retrofit2.http.Query

class HomeViewModel : BaseViewModel<HomeIntent>() {

    private val repository = HomeRepository()

    /**
     * 获取视频类型数据
     */
    fun getVideoType() {
        viewModelScope.launch(Dispatchers.IO) {
                httpRequest(repository.getVideoType() as Flow<Res<Any>>, StateType.VIDEO_TYPE)
        }
    }
    fun getVideoList(labelId:String,page: Int,size: Int) {
        viewModelScope.launch(Dispatchers.IO) {
            httpRequest(repository.getVideoList(labelId,page,size) as Flow<Res<Any>>, StateType.VIDEO_MAIN)
        }
    }



    override fun handleIntent(it: UiIntent) {

    }
}
